import { GTileList } from "../../../../com/mui/controls/GTileList";
import { ScrollBarDirection } from "../../../../fl/controls/ScrollBarDirection";
import { MailRender } from "./MailRender";
import { GlobalClass } from "../../../../com/mui/core/GlobalClass";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { SMail } from "../../../../Message/Game/SMail";
//class MailListPanel
    
    export  class MailListPanel extends GTileList
    {
        constructor()
        {
            super();
            this.mouseChildren = true;
            this.initTile();
            return;
        }

        /* internal  */initTile(): void
        {
            this.setSize(281, 288);
            this.columnWidth = 281;
            this.rowHeight = 46;
            this.direction = ScrollBarDirection.VERTICAL;
            this.horizontalGap = 3;
            this.verticalGap = 3;
            this.setStyle("skin", new Object /* flash.display.Bitmap */());
            this.setStyle("cellRenderer", MailRender);
            this.setRendererStyle("overSkin", GlobalClass.getBitmap("MailreadAcross"));
            return;
        }

        public updateProvider(arg1: Array<any>): void
        {
            var loc1=null;
            var loc2=null;
            var loc3=0;
            if (!(null == arg1) && arg1.length > 0) 
            {
                loc1 = new DataProvider();
                loc3 = 0;
                while (loc3 < arg1.length) 
                {
                    loc2 = arg1[loc3] as SMail;
                    loc1.addItem({"smail": loc2, "status": loc2.status, "index": loc3});
                    ++loc3;
                }
                loc1.sortOn(["status", "index"], [Array.NUMERIC, Array.NUMERIC]);
                this.dataProvider = loc1;
            }
            else 
            {
                this.dataProvider = new DataProvider();
            }
            return;
        }

        public reSortDataProvider(): void
        {
            var loc1=[];
            var loc2=this.dataProvider.sortOn(["status", "index"], [Array.NUMERIC, Array.NUMERIC]);
            var loc3=0;
            while (loc3 < loc2.length) 
            {
                loc1.push(loc2[loc3]["smail"]);
                ++loc3;
            }
            this.updateProvider(loc1);
            return;
        }
    }
